package com.wantong.jianpu.models;

import com.trello.rxlifecycle2.LifecycleProvider;
import com.wantong.jianpu.beans.ConfirmTourBean;
import com.wantong.jianpu.beans.DeviceListBean;
import com.wantong.jianpu.beans.InspectionDetailBean;
import com.wantong.jianpu.net.BaseObserver;
import com.wantong.jianpu.net.HttpUtils;
import com.wantong.jianpu.net.RetrofitUtil;

import java.util.List;
import java.util.Map;

import io.reactivex.Observable;
import me.goldze.mvvmhabit.base.BaseModel;

/**
 * @author PACY
 * @date 2022/5/24
 * description:
 */
public class DeviceModel extends BaseModel {
    /**
     *  查询设备巡检列表
     * @param observer
     * @param lifecycle
     */
    public void getDeviceList(Map<String,Object> map, BaseObserver<DeviceListBean> observer, LifecycleProvider lifecycle) {
        Observable observable = RetrofitUtil.getApiService().getDeviceList(map);
        RetrofitUtil.composeToSubscribe(observable, observer, lifecycle);
    }


    /**
     *  查询设备巡检详情
     * @param observer
     * @param lifecycle
     */
    public void getDeviceDetail(String id, BaseObserver<InspectionDetailBean> observer, LifecycleProvider lifecycle) {
        Observable observable = RetrofitUtil.getApiService().getDeviceDetail(id);
        RetrofitUtil.composeToSubscribe(observable, observer, lifecycle);
    }

    /**
     *  巡检确认
     * @param observer
     * @param lifecycle
     */
    public void inspection_confirm(Map<String,Object> map, BaseObserver observer, LifecycleProvider lifecycle) {
        Observable observable = RetrofitUtil.getApiService().inspection_confirm(HttpUtils.buildBody(map));
        RetrofitUtil.composeToSubscribe(observable, observer, lifecycle);
    }

    /**
     *  完成本次巡检
     * @param observer
     * @param lifecycle
     */
    public void completeInspection(String id, BaseObserver observer, LifecycleProvider lifecycle) {
        Observable observable = RetrofitUtil.getApiService().completeInspection(id);
        RetrofitUtil.composeToSubscribe(observable, observer, lifecycle);
    }

    /**
     *  获取巡检确认列表
     * @param observer
     * @param lifecycle
     */
    public void recordList(Map<String,Object> map, BaseObserver<ConfirmTourBean> observer, LifecycleProvider lifecycle) {
        Observable observable = RetrofitUtil.getApiService().recordList(map);
        RetrofitUtil.composeToSubscribe(observable, observer, lifecycle);
    }
}
